package com.fcscs.cservice.ws.endpoint;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;

import com.fcscs.cservice.ws.schema.entertainmentservice.GetEntertainmentRequest;
import com.fcscs.cservice.ws.schema.entertainmentservice.GetEntertainmentResponse;
import com.fcscs.ecms.service.ECMSEntertainmentManager;

/**
 * @author pvttinh
 * 
 */

@Endpoint
public class EntertainmentServiceEndpoint {

	@Autowired
	ECMSEntertainmentManager entertainmentMgr;

	/**
	 * 
	 * @param req
	 * @return
	 */
	@PayloadRoot(localPart = CServiceWSConstants.GET_ENTERTAINMENT_RQ, namespace = CServiceWSConstants.ENTERTAINMENT_SERVICE_NAMESPACE_URI)
	@ResponsePayload
	public GetEntertainmentResponse getEntertainmentUrl(@RequestPayload GetEntertainmentRequest req) {

		GetEntertainmentResponse resp = new GetEntertainmentResponse();
		try{
			resp.setEntertainmentUrl(this.entertainmentMgr.getEntertainmentUrl(req.getModuleId(), req.getOrgId(), req.getPropId()));
			resp.setSuccess(true);
		}catch (Exception e) {
			// TODO: handle exception
			resp.setSuccess(false);
			resp.setErrorMessage(e.getMessage());
		}
		
		return resp;
	}
}
